package org.example.controller.impl;

import org.apache.ibatis.annotations.Param;
import org.example.controller.HelpController;
import org.example.domain.Help;
import org.example.domain.HelpInfo;
import org.example.domain.response.ResponseResult;
import org.example.services.impl.HelpServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/helps")
public class HelpControllerImpl implements HelpController {
    @Autowired
    private HelpServiceImpl helpService;
    @Override
    @PostMapping("/1")
    public ResponseResult saveHelp(@RequestBody Help help) {
        return helpService.saveHelp(help);
    }

    @Override
    @DeleteMapping("/1/{helpId}")
    public ResponseResult deleteHelp(@PathVariable Integer helpId) {
        return helpService.deleteHelp(helpId);
    }

    @Override
    @PutMapping("/1")
    public ResponseResult updateHelp(@RequestBody Help help) {
        return helpService.updateHelp(help);
    }

    @Override
    @GetMapping("/1/{helpId}/{pageSize}/{currentPage}")
    public ResponseResult selectHelpById(@PathVariable Integer helpId,@PathVariable int currentPage,@PathVariable int pageSize) {
        return helpService.selectHelpById(helpId,currentPage,pageSize);
    }



    @Override
    @PostMapping("/2")
    public ResponseResult saveHelpInfo(@RequestBody HelpInfo helpInfo) {
        return helpService.saveHelpInfo(helpInfo);
    }

    @Override
    @PutMapping("/2")
    public ResponseResult updateHelpInfo(@RequestBody HelpInfo helpInfo) {
        return helpService.updateHelpInfo(helpInfo);
    }

    @Override
    @DeleteMapping("/2/{helpInfoId}")
    public ResponseResult deleteHelpInfo(@PathVariable Integer helpInfoId) {
        return helpService.deleteHelpInfo(helpInfoId);
    }

    @Override
    @GetMapping("/2/{helpInfoId}/{pageSize}/{currentPage}")
    public ResponseResult selectHelpInfo(@PathVariable Integer helpInfoId,@PathVariable int currentPage,@PathVariable int pageSize) {
        return helpService.selectHelpInfo(helpInfoId,currentPage,pageSize);
    }
    

    @Override
    @GetMapping("/1/{pageSize}/{currentPage}")
    public ResponseResult getHelpByPage(@PathVariable int currentPage,@PathVariable int pageSize) {
        return helpService.getHelpByPage(currentPage,pageSize);
    }

    @Override
    @GetMapping("/2/{pageSize}/{currentPage}")
    public ResponseResult getHelpInfoByPage(@PathVariable int currentPage,@PathVariable int pageSize) {
        return helpService.getHelpInfoByPage(currentPage,pageSize);
    }

}
